home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Development Kits / MPW etc / MPW-PR / Interfaces&Libraries / Interfaces / CIncludes / stdlib.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-11  |  3.6 KB  |  185 lines  |  [TEXT/MPS ]

  1. /*
  2.     StdLib.h -- General utilities
  3.  
  4.     Copyright Apple Computer,Inc.    1987, 1990, 1993-1995
  5.     All rights reserved.
  6.  
  7. */
  8.  
  9.  
  10. #ifndef __STDLIB__
  11. #define __STDLIB__
  12.  
  13. /*
  14.  * Get common declarations 
  15.  */
  16.  
  17. #include <NullDef.h>
  18. #include <SizeTDef.h>
  19. #include <WCharTDef.h>
  20.  
  21. #ifdef powerc
  22. #pragma options align=power
  23. #endif
  24. struct div_t {
  25.     int quot;            /* quotient */
  26.     int rem;            /* remainder */
  27. } ;
  28. #ifdef powerc
  29. #pragma options align=reset
  30. #endif
  31. typedef struct div_t div_t;
  32.  
  33. #ifdef powerc
  34. #pragma options align=power
  35. #endif
  36. struct ldiv_t {
  37.     long int quot;        /* quotient */
  38.     long int rem;        /* remainder */
  39. };
  40. #ifdef powerc
  41. #pragma options align=reset
  42. #endif
  43. typedef struct ldiv_t ldiv_t;
  44.  
  45. #define EXIT_FAILURE 1
  46. #define EXIT_SUCCESS 0
  47.  
  48. #define RAND_MAX 32767
  49.  
  50. #define MB_CUR_MAX 1
  51.  
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif
  55.  
  56.  
  57. #if defined (__powerc) || defined (powerc) || defined (__CFM68K__)
  58.     #pragma import on
  59. #endif
  60.  
  61.  
  62. /*
  63.  *    String conversion functions
  64.  */
  65.  
  66. double atof (const char *nptr);
  67. int atoi (const char *nptr);
  68. long int atol (const char *nptr);
  69. double strtod (const char *nptr, char **endptr);
  70. long int strtol (const char *nptr, char **endptr, int base);
  71. unsigned long int strtoul (const char *nptr, char **endptr, int base);
  72.  
  73.  
  74. /*
  75.  *    Pseudo-random sequence generation functions
  76.  */
  77.  
  78. int rand (void);
  79. void srand (unsigned int seed);
  80.  
  81.  
  82. /*
  83.  *    Memory management functions
  84.  */
  85.  
  86. void *calloc (size_t nmemb, size_t size);
  87. void free (void *ptr);
  88. void *malloc (size_t size);
  89. void *realloc (void *ptr, size_t size);
  90.  
  91. #if __VEC__
  92. void *vec_calloc (size_t nmemb, size_t size);
  93. void vec_free (void *ptr);
  94. void *vec_malloc (size_t size);
  95. void *vec_realloc (void *ptr, size_t size);
  96. #endif
  97.  
  98. /*
  99.  *    Communication with the environment
  100.  */
  101.  
  102. void abort (void);
  103. int atexit (void (*func)(void));
  104. void exit (int status);
  105. char *getenv (const char *name);
  106. int system (const char *string);
  107.  
  108.  
  109. /*
  110.  *    Searching and sorting utilities
  111.  */
  112.  
  113. void *bsearch (const void *key, const void *base,
  114.                size_t nmemb, size_t size,
  115.                int (*compar)(const void *, const void *));
  116. void qsort (void *base, size_t nmemb, size_t size,
  117.             int (*compar)(const void *, const void *));
  118.  
  119.  
  120. /*
  121.  *    Integer arithmetic functions
  122.  */
  123.  
  124. int abs (int j);
  125. div_t div (int numer, int denom);
  126. long int labs (long int j);
  127. ldiv_t ldiv (long int numer, long int denom);
  128.  
  129.  
  130. /*
  131.  *    Multibyte functions
  132.  */
  133.  
  134. int mblen (const char *s, size_t n);
  135. int mbtowc (wchar_t *pwc, const char *s, size_t n);
  136. int wctomb (char *s, wchar_t wchar);
  137. size_t mbstowcs (wchar_t *pwcs, const char *s, size_t n);
  138. size_t wcstombs (char *s, const wchar_t *pwcs, size_t n);
  139.  
  140. /*
  141.  *  Apple extentions
  142.  */
  143.  
  144. /* CFront can't handle the pretty version of this conditional 
  145. #if defined (__useAppleExts__) || \
  146.     ((defined (applec) && ! defined (__STDC__)) || \
  147.      (defined (__PPCC__) && __STDC__ == 0))
  148. */
  149. #if defined (__useAppleExts__) || ((defined (applec) && ! defined (__STDC__)) || (defined (__PPCC__) && __STDC__ == 0))
  150.  
  151. void _exit (int status);
  152. int setenv(const char *varName, const char *value);
  153. #define putenv(x, y) setenv((x), (y))
  154.  
  155. #endif
  156.  
  157. #if _LONG_LONG   /* Is long long supported? */
  158.  
  159. struct lldiv_t {
  160.     long long int quot;        /* quotient  */
  161.     long long int rem;        /* remainder */
  162. };
  163.  
  164. typedef struct lldiv_t lldiv_t;
  165.  
  166. long long int llabs (long long int j);
  167. lldiv_t lldiv (long long int numer, long long int denom);
  168. long long int strtoll (const char *nptr, char **endptr, int base);
  169. unsigned long long int strtoull (const char *nptr, char **endptr, int base);
  170. long long int atoll (const char *nptr);
  171.  
  172. #endif  /* If _LONG_LONG is supported */
  173.  
  174.  
  175. #if defined (__powerc) || defined (powerc) || defined (__CFM68K__)
  176.     #pragma import off
  177. #endif
  178.  
  179.  
  180. #ifdef __cplusplus
  181. }
  182. #endif
  183.  
  184. #endif
  185.